<template>
  <i-frame :src="openUrl" />
</template>

<script>
import iFrame from '@/components/IFrameView/index'
import { getAuthentication } from '@/utils/store'

export default {
  name: 'JmView',
  components: { iFrame },
  props: {
    reportID: {
      type: [String],
      required: false,
      default: ''
    },
  },
  data() {
    return {
      openUrl: ''
    }
  },
  created() {
    if (this.reportID.length != 0) {
      this.openUrl = process.env.VUE_APP_URL_PREFIX + `${process.env.VUE_APP_MODULE_REPORT_API}/jmreport/view/` + this.reportID + '?access_token=' +  getAuthentication()
    } else {
      this.openUrl = process.env.VUE_APP_URL_PREFIX + `${process.env.VUE_APP_MODULE_REPORT_API}/jmreport/view/` + this.$route.path.substring(this.$route.path.lastIndexOf("/") + 1) + '?access_token=' + getAuthentication()
    }
  }
}
</script>
